﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Dataweb.NShape;
using cz.zcu.PreSti.Guide;

namespace cz.zcu.PreSti.Application
{
	/// <summary>
	/// Provides presentation layer of the PreSti guides.
	/// </summary>
	public partial class GuideWindow : Form
	{
		private Project project;
		private Diagram diagram;
		private GuideParent guide;
		private MainWindow mainWindow;
		private List<Property> listArguments;
		private string type;

		/// <summary>
		/// Initializes a new instance of the <see cref="GuideWindow"/> class.
		/// </summary>
		/// <param name="project">The project.</param>
		/// <param name="diagram">The diagram.</param>
		/// <param name="type">The type.</param>
		/// <param name="mainWindow">The main window.</param>
		public GuideWindow(Project project, Diagram diagram, String type, MainWindow mainWindow)
		{
			InitializeComponent();
			this.project = project;
			this.diagram = diagram;
			this.type = type;
			this.mainWindow = mainWindow;
			this.listArguments = new List<Property>();
			InitializeArguments();
 
			  if (type == "random")
			  {
				guide = new RandomGuide(project, diagram, listArguments, this);
			  }
			  if (type == "sequential")
			  {
				  guide = new SequentialGuide(project, diagram, listArguments, this);
			  }
		}

		/// <summary>
		/// Initializes the arguments: sets list of (textbox, labels) group.
		/// </summary>
		private void InitializeArguments()
		{
			listArguments.Add(new Property(textBox1, label1));
			listArguments.Add(new Property(textBox2, label2));
			listArguments.Add(new Property(textBox3, label3));
			listArguments.Add(new Property(textBox4, label4));
			listArguments.Add(new Property(textBox5, label5));
			listArguments.Add(new Property(textBox6, label6));
			listArguments.Add(new Property(textBox7, label7));
			listArguments.Add(new Property(textBox8, label8));
		}

		/// <summary>
		/// Fills the comboxes: provides initialization.
		/// </summary>
		private void FillComboxes()
		{
			CBStimuliType.Items.AddRange(new object[] { "Text", "Image", "Sound" });            
			CBAlignmentH.Items.AddRange(new object[] { "none", "left", "center", "right" });
			CBAlignmentV.Items.AddRange(new object[] { "none", "up", "center", "bottom" });
			CBStimuliType.SelectedItem = CBStimuliType.Items[0];
			CBAlignmentV.SelectedItem = CBAlignmentV.Items[0];
			CBAlignmentH.SelectedItem = CBAlignmentH.Items[0];
		}


		/// <summary>
		/// Handles the Click event of the BTCreateGraph control: creates graph of a guide.
		/// </summary>
		/// <param name="sender">The source of the event.</param>
		/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
		private void BTCreateGraph_Click(object sender, EventArgs e)
		{
			guide.CreateGraph();
			this.Close();
		}
		/// <summary>
		/// Handles the MouseEnter event of the flowLayoutPanel1 control: sets scroll settings.
		/// </summary>
		/// <param name="sender">The source of the event.</param>
		/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
		private void flowLayoutPanel1_MouseEnter(object sender, EventArgs e)
		{
			flowLayoutPanel1.Focus();
		}

		/// <summary>
		/// Handles the Click event of the BTRun control: starts running of presentation.
		/// </summary>
		/// <param name="sender">The source of the event.</param>
		/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
		private void BTRun_Click(object sender, EventArgs e)
		{
			mainWindow.Launch();
			guide.CreateGraph();
			this.Close();
		}

		/// <summary>
		/// Handles the Load event of the GuideWindow control.
		/// </summary>
		/// <param name="sender">The source of the event.</param>
		/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
		private void GuideWindow_Load(object sender, EventArgs e)
		{
			FillComboxes();
		}  
	}
}
